from django.forms import Form, CharField, PasswordInput, ModelForm
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.contrib.auth.forms import PasswordChangeForm, UserChangeForm

class RegistroUsuarioForm(UserCreationForm):
	def __init__(self,*args,**kwargs):
		super(RegistroUsuarioForm,self).__init__(*args,**kwargs)
		self.fields['username'].label = "Usuario"
		self.fields['username'].help_text = ""
		self.fields['password2'].help_text = ""
		self.fields['first_name'].label = "Nombre"
		self.fields['last_name'].label = "Apellido"
		self.fields['email'].label = "Email"
		self.fields['first_name'].required = True
		self.fields['last_name'].required = True
		self.fields['email'].required = True

	class Meta:
		model = User
		fields = ('username','first_name','last_name','email')

class EditarUsuarioForm(ModelForm):
	def __init__(self, *args, **kwargs):
		super(EditarUsuarioForm, self).__init__(*args, **kwargs)
		self.fields['first_name'].label = "Nombre"
		self.fields['last_name'].label = "Apellido"
		self.fields['email'].label = "Email"
		self.fields['first_name'].required = True
		self.fields['last_name'].required = True
		self.fields['email'].required = True

	class Meta:
		model = User
		fields = ('first_name','last_name','email')

class EditarPasswordForm(PasswordChangeForm):
	def __init__(self, user, **kwargs):
		super(EditarPasswordForm, self).__init__(user=user, **kwargs)

	class Meta:
		model = User

class LoginForm(Form):
	username = CharField(max_length=100, label="Usuario")
	password = CharField(widget=PasswordInput, label="Password")